// Upgrade NOTE: commented out 'float4x4 _Object2World', a built-in variable
// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
// Upgrade NOTE: replaced 'glstate_matrix_mvp' with 'UNITY_MATRIX_MVP'


Shader  "Custom/FlatColourClip" {

	Properties
	 {
 _Colour ("Colour", Color) = (1,1,1,1)
 _Plane ("_Plane", Vector) = (0,1,0,1)
}

	

	SubShader
     {
  Tags { "QUEUE"="Geometry" "RenderType"="Opaque" }

    LOD 100
	Pass
	{
	
	

	CGPROGRAM
	#pragma vertex vert
	#pragma fragment frag
	#include "UnityCG.cginc"

	struct VertexInput {
    fixed4 vertex : POSITION;
	fixed3 xlv_TEXCOORD0 : TEXCOORD0;
    //fixed2 xlv_TEXCOORD1 : TEXCOORD1;
    //fixed3 xlv_TEXCOORD2 : TEXCOORD2;
    //fixed3 xlv_TEXCOORD3 : TEXCOORD3;
    //fixed4 tangent : TANGENT;
    //fixed3 normal : NORMAL;
    //fixed3 xlv_COLOR0 : COLOR;
	//VertexInput
	};


	struct VertexOutput {
	fixed4 pos : SV_POSITION;
    UNITY_FOG_COORDS(1)
    //fixed3 xlv_COLOR0 : COLOR;
	fixed3 xlv_TEXCOORD0 : TEXCOORD0;
    //fixed2 xlv_TEXCOORD1 : TEXCOORD1;
    //fixed3 xlv_TEXCOORD2 : TEXCOORD2;
    //fixed3 xlv_TEXCOORD3 : TEXCOORD3;
	//VertexOutput
	};

	

 
 
 // float4x4 _Object2World;
 //float4 xlv_TEXCOORD0;


	

 float4 _Colour;
 float4 _Plane;
 float4 xlv_TEXCOORD0;




	VertexOutput vert (VertexInput v)
	{
	VertexOutput o;
	o.pos = UnityObjectToClipPos (v.vertex);
	//o.xlv_TEXCOORD0 = TRANSFORM_TEX(v.xlv_TEXCOORD0, _MainTex);
	
  //o.pos = (UNITY_MATRIX_MVP * v.vertex);
  o.xlv_TEXCOORD0 = mul(unity_ObjectToWorld , v.vertex);




    UNITY_TRANSFER_FOG(o,o.vertex);
   
	return o;
	}


	fixed4 frag(VertexOutput i) : SV_Target
    {
    //fixed4 tmpvar_2 = tex2D(_MainTex, i.uv);
	//UNITY_APPLY_FOG(i.fogCoord, tmpvar_2);
	
  float x_1;
  x_1 = (dot (i.xlv_TEXCOORD0.xyz, _Plane.xyz) - _Plane.w);
  if ((x_1 < 0.0)) {
    discard;
  };
   return _Colour;
	}
	ENDCG
	}
  }
}

